/**
 * jims
 */
package com.jims.api.v1.controller.doctor;


import com.jims.master.common.data.Message;
import com.jims.master.common.data.StringData;
import com.jims.master.common.utils.SecurityUtil;
import com.jims.master.common.web.BaseController;
import com.jims.master.modules.patient.myFamily.entity.HfDailyCheckShow;
import com.jims.master.modules.patient.myFamily.service.HfDailyCheckShowService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * Controller
 * @author jict
 * @version 2018-07-30
 */
@RestController
@RequestMapping(value = "/hfDailyCheckShow")
public class HfDailyCheckShowController extends BaseController {

	@Autowired
	private HfDailyCheckShowService hfDailyCheckShowService;

	@RequestMapping(value = "V100/save",method ={RequestMethod.GET,RequestMethod.POST})
	public String save(HfDailyCheckShow hfDailyCheckShow) {
		Message mes = new Message();
		int i=hfDailyCheckShowService.save(hfDailyCheckShow);
        if(i>0){
        	mes.setData("保存成功");
        }else{
			mes.setData("保存失败");
        }
        return SecurityUtil.encryptMsgData(mes);
	}

	@RequestMapping(value = "V100/saveHfDailyCheckShow",method ={RequestMethod.GET,RequestMethod.POST})
	public String save(String isShow,String baseInfo,String item) {
		Message mes = new Message();
		String[] isShows = isShow.split(",");
		String[] items = item.split(",");
		for (int i = 0; i < isShows.length; i++) {
			HfDailyCheckShow hfDailyCheckShow = new HfDailyCheckShow();
			hfDailyCheckShow.setBaseInfo(baseInfo);
			hfDailyCheckShow.setIsShow(isShows[i]);
			hfDailyCheckShow.setItem(items[i]);
			hfDailyCheckShowService.save(hfDailyCheckShow);
		}
		mes.setData("保存成功");
		return SecurityUtil.encryptMsgData(mes);
	}

	@RequestMapping(value = "V100/updateHfDailyCheckShow",method ={RequestMethod.GET,RequestMethod.POST})
	public String save(String isShow,String id) {
		Message mes = new Message();
		String[] isShows = isShow.split(",");
		String[] ids = id.split(",");
		for (int i = 0; i < isShows.length; i++) {
			HfDailyCheckShow hfDailyCheckShow = hfDailyCheckShowService.get(ids[i]);
			hfDailyCheckShow.setIsShow(isShows[i]);
			hfDailyCheckShowService.save(hfDailyCheckShow);
		}
		mes.setData("保存成功");
		return SecurityUtil.encryptMsgData(mes);
	}

	@RequestMapping(value = "V100/selectList",method ={RequestMethod.GET,RequestMethod.POST})
	public String selectList(String baseinfo) {
		Message mes = new Message();
		List<HfDailyCheckShow> list=hfDailyCheckShowService.selectList(baseinfo);
		mes.setData(list);
		return SecurityUtil.encryptMsgData(mes);
	}

	@RequestMapping(value = "V100/delete",method ={RequestMethod.GET,RequestMethod.POST})
	public String delete(HfDailyCheckShow hfDailyCheckShow) {
		Message mes = new Message();
		int i=hfDailyCheckShowService.delete(hfDailyCheckShow);
        if(i>0){
			mes.setData("保存成功");
        }else{
			mes.setData("保存失败");
        }
		return SecurityUtil.encryptMsgData(mes);
	}
	public final static String id = "sys_login";
}